﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
namespace BUS
{
    public class GiamGiaBus
    {
        public static List<DTO.GiamGiaDto> LayDanhSachGiamGia()
        {
            return DAO.GiamGiaDao.LayDanhSachGiamGia();
        }
        public static DTO.GiamGiaDto LayGiamGiaTheoID(int id)
        {
            return DAO.GiamGiaDao.LayDanhGiamGiaTheoID(id);
        }

        public static int LayTiLeGiamGia(int Diem)
        {
            int currentGiamGia = 0;
            List<DTO.GiamGiaDto> lstGiamGia = DAO.GiamGiaDao.LayDanhSachGiamGia();
            for (int i = 0; i < lstGiamGia.Count; i++)
            {
                if (Diem >= lstGiamGia[i].ThangDiem)
                    currentGiamGia = lstGiamGia[i].MucGiam;
                else
                    return currentGiamGia;
            }

            return currentGiamGia;
        }
    }
}
